package com.xxxx.seckill.controller;


import com.xxxx.seckill.pojo.SeckillOrder;
import com.xxxx.seckill.pojo.User;
import com.xxxx.seckill.service.IOrderService;
import com.xxxx.seckill.service.ISeckillOrderService;
import com.xxxx.seckill.vo.RespBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author zhoubin
 * @since 2022-08-17
 */
@Controller
@RequestMapping("/user")
@Slf4j
public class UserController {

    @Autowired
    private ISeckillOrderService iSeckillOrderService;

    /**
     * 用户信息(测试)
     *
     * @param user
     * @return
     */
    @RequestMapping("/info")
    @ResponseBody
    public RespBean info(User user) {
        log.info("user:{}", user);
        return RespBean.success(user);
    }

    @GetMapping("/test")
    @ResponseBody
//    @Transactional
    public String test(){
        SeckillOrder seckillOrder = new SeckillOrder(111l, 21l, 30l, 40l);
        boolean save = iSeckillOrderService.save(seckillOrder);
        int i = 1/0;
        return save==true? "添加成功":"添加失败";
    }
}
